#include "list.h"
#include <cstdio>

bool hasCycle(ListNode* head){
  ListNode* fast,*slow;
  fast = slow = head;

  while(fast != NULL && fast->next != NULL){
    fast = fast->next->next;
    slow = slow->next;

    if(fast == slow){
      return true;
    }
  }

  return false;
}